<template>
  <div class="videocontain">
    <div class="videoPlay">
      <video
        controls="controls"
        autoplay="autoplay"
        width="1200"
        height="675"
        class="video"
        :src="mvplay.mvUrl"
      ></video>
      <div class="videoName">
        <div class="name">{{ mvplay.mvName }}</div>
        <div class="icon">
          <i class="iconfont icon-shouji"></i>
          <i class="iconfont icon-fenxiang"></i>
          <i class="iconfont icon-download-fill"></i>
        </div>
      </div>
    </div>
    <!--  -->
    <div class="youLive">
      <h3>猜你喜欢</h3>
      <ul class="detailList">
        <li
          class="item"
          v-for="(item, index) in randomMv"
          :key="index"
          @click="changeMv(item.name, item.mvUlr)"
        >
          <img :src="item.img" class="imgName" alt="faf" />
          <a
            href="#"
            style="text-decoration: none; color: #000000"
            class="vidioName"
          >
            {{ item.name }}
          </a>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
// 获取类型id
import getcatgory from "../../api/mvRequest/getcatgory";
export default {
  name: "MvPlayer",
  data() {
    return {
      randomMv: [],
      mvplay: {
        mvUrl: "",
        mvName: "",
      },
    };
  },
  async mounted() {
    // 使用响应式数据渲染
    this.mvplay.mvUrl = this.$route.query.url;
    this.mvplay.mvName = this.$route.query.name;
    // 推荐视频
    let { datas } = await getcatgory("/video/timeline/recommend");
    // console.log(datas);
    // 整理数据
    this.randomMv = datas.map((item) => {
      return {
        img: item.data.coverUrl,
        name: item.data.title,
        mvUlr: item.data.urlInfo.url,
      };
    });
  },
  methods: {
    changeMv(name, url) {
      this.mvplay.mvUrl = url;
      this.mvplay.mvName = name;
    },
  },
};
</script>
<style scoped>
.videoPlay {
  width: 100%;
  background: rgb(62, 62, 62);
}
.video {
  width: 1228px;
  height: 777px;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}
.videoName {
  padding: 0 135px;
  height: 82px;
  line-height: 82px;
  font-size: 28px;
  display: flex;
  justify-content: space-between;
}
.icon {
  display: flex;
}
.iconfont {
  font-size: 30px;
  margin-right: 15px;
}
/* 猜你喜欢 */
.youLive {
  padding-left: 135px;
}
.detailList {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: nowrap;
  width: 1280px;
}
.item {
  width: 140px;
  height: 110px;
  margin-right: 20px;
  margin-bottom: 10px;
}
.imgName {
  display: block;
  width: 140px;
  height: 78px;
  border-radius: 10px;
}
.vidioName {
  display: block;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
</style>